// app.js
App({
  onLaunch() {
    const systemInfo = wx.getSystemInfoSync()
    const {
      statusBarHeight,
      windowWidth,
      windowHeight,
      model,
      screenHeight,
      safeArea,
    } = systemInfo
    // 胶囊按钮位置信息
    const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
    this.globalData.menuButtonInfo = menuButtonInfo;
    const {
      top,
      height,
      width
    } = menuButtonInfo;
    // 导航栏高度 = 状态栏到胶囊的间距（胶囊距上距离-状态栏高度） * 2 + 胶囊高度 + 状态栏高度
    this.globalData.navBarHeight = (top - statusBarHeight) * 2 + height + statusBarHeight;
    this.globalData.menuTop = top;
    this.globalData.menuHeight = height;
    this.globalData.menuWidth = width;
    this.globalData.windowWidth = windowWidth;
    this.globalData.windowHeight = windowHeight;
    this.globalData.screenHeight = screenHeight;
    // 判断iphoneX及以上机型
    this.globalData.isIphoneX = screenHeight - safeArea.bottom === 34;
    // 判断iphone
    this.globalData.isIphone = model.indexOf('iPhone') !== -1
  },
  globalData: {
    menuButtonInfo: null,
    navBarHeight: 0,
    menuTop: 0,
    menuHeight: 0,
    menuWidth: 0,
    windowWidth: 0,
    windowHeight: 0,
    screenHeight: 0,
  }
})